package cn.amarone.wineblog.config.exception;

import cn.amarone.wineblog.common.appointment.Result;
import cn.amarone.wineblog.common.appointment.Result.Type;
import java.util.Date;
import lombok.extern.slf4j.Slf4j;
import org.springframework.security.access.AccessDeniedException;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;

@ControllerAdvice
@Slf4j
public class ExceptionHandle {



  @ExceptionHandler(value = AccessDeniedException.class)
  public Result accessExceltion(Exception e) {
    log.error("权限校验异常{}", e.toString());
    Result result = new Result(Type.ERROR, e.getMessage());
    result.put("disposeDate",new Date());
    return result;
  }

  @ExceptionHandler(value = Exception.class)
  public Result unKnowExceltion(Exception e) {
    log.error("{}", e.toString());
    Result result = new Result(Type.ERROR, e.getMessage());
    result.put("disposeDate",new Date());
    return result;
  }
}
